﻿using System.ComponentModel;
using System.Windows.Forms;
using HossMvp.Core;
using Sample.Views;

namespace Sample
{
    public partial class PreferencesForm : Form
    {
        public PreferencesForm(IPresenter<AbstractModelManager, AbstractViewManager> presenter)
        {
            this.InitializeComponent();
            
            // create and initialize content provider, register all form controls (IComponent implementors)
            var contentProvider = new PreferencesView.PreferencesViewContentProvider(this);
            contentProvider.RegisterControls<IComponent>(this);

            // the panel in which actual preference panels are hosted; actually, the "host" panel is a property of
            // the split cntainer, and therefore is not registered during the controls registration process above.
            contentProvider.Set("panelHost", this.splitContainer1.Panel2);

            // create the view with the augmented provider
            presenter.ViewManager.Create<PreferencesView>("PreferencesView", contentProvider);
        }
    }
}
